home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Merciful 1
/
Merciful - Disc 1.iso
/
software
/
m
/
math_vision
/
mathvisionv2.1b.dms
/
mathvisionv2.1b.adf
/
Arexx.CLI
/
Zoom.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1992-02-14
|
5KB
|
133 lines
/* ZOOM.REXX, an ARexx program for MathVision, 3-Sep-89 dh
This generic Arexx program will allow you to create a series of zoomed
pictures in contour plot mode. It is assumed that you have already entered
the appropriate functions, colors and setting in MathVision.
It takes into account the fact that as you zoom in closer, you must use
smaller increments.
To use this program, you must edit this file, and put in the appropriate
values in the User Settings section which follows.
The 'BaseFilename' is the basic name which will be used for all the pictures.
For example, if you put "PLOTS:PIC", the files will be named "PLOTS:PIC0000",
"PLOTS:PIC0001", "PLOTS:PIC0002", and so on. The number of the picture is
appended to the basic file name.
'Pictures' is how many frames you want in this zoom. A higher setting
here will give you smoother animation. The pictures will be numbered starting
at 0 and going up to Pictures-1.
'StartPicture' is useful if your plotting has to be restarted because of
some interrupt, like a Drastic Power Failure or Real Work. Just plug in the
number of the next picture to plot, and it will start right there. Normally
this value is 0. This lets you work on your computer during the day, and
resume the plotting during the night.
You must give the starting and ending coordinates of your zoom. These
are given in the variables xmin_start, xmin_end, and etc.
*/
/*============================== User Settings =============================*/
NUMERIC DIGITS 15
Pictures = 100 /* Number of pictures to plot */
StartPicture = 0 /* Picture to start plotting with */
BaseFilename = "Mandelbrot_Zoom:Pic" /* Basic pathname for pictures */
xmin_start = -2 /* coordinates of starting (big) picture */
xmax_start = 2
ymin_start = -1.5
ymax_start = 1.5
xmin_end = -0.7372 /* coordinates of ending (small) picture */
xmax_end = -0.7367
ymin_end = 0.2012
ymax_end = 0.2016
/*==========================================================================*/
/* THEORY OF OPERATION:
Zooming was not a simple as I first imagined. Suppose you have a frame
which is 10 centimeters square, and you wish to zoom in on a picture that
is 1 centimeter square, and you wish to zoom in by 1-centimeter increments.
The first zoom, from 10 to 9, gives you a zoom factor of 10/9, or 111%.
But as you get closer, the zoom factor increases. From 9 to 8, the zoom
factor is 9/8, or 112%, and from 2 to 1 the zoom factor is 2/1, or 200%.
As you get closer, you zoom faster, which is not the effect you want.
One way to get around this problem is to use logarithms. I won't bore
you with the details, but we first convert our numbers to logarithms so
we can make a linear zoom, and then convert back to the numbers we want.
I consider the x and y dimensions separately, in case the aspect ratio
changes.
As for the implementation, I wrote two little functions at the end of
the program which kick MathVision to do some logarithmic stuff. This is
necessary because I could not do the logarithms in ARexx, but MathVision has
no problem with it.
*/
ADDRESS "MathVision"
OPTIONS RESULTS /* We need answers */
OPTIONS FAILAT 1 /* everything is fatal */
SIGNAL ON ERROR /* if error, goto ERROR: */
xstart_span = xmax_start - xmin_start /* compute handy variables */
ystart_span = ymax_start - ymin_start
xend_span = xmax_end - xmin_end
yend_span = ymax_end - ymin_end
log_xstart_span = log(xstart_span)
log_ystart_span = log(ystart_span)
log_xend_span = log(xend_span )
log_yend_span = log(yend_span )
DO PictureNumber = StartPicture TO Pictures-1 /* for each picture...*/
Filename = BaseFilename||Right(PictureNumber,4,"0") /* status report */
SAY "Plotting:"Filename
mult = (PictureNumber) / (Pictures-1) /* 0..1 */
t = log_xstart_span - ((log_xstart_span - log_xend_span) * mult)
xmult = (exp(t)-xend_span)/(xstart_span - xend_span)
t = log_ystart_span - ((log_ystart_span - log_yend_span) * mult)
ymult = (exp(t)-yend_span)/(ystart_span - yend_span)
/* plug in the new values */
Xmin xmin_end - (xmin_end - xmin_start)*xmult
Xmax xmax_end - (xmax_end - xmax_start)*xmult
Ymin ymin_end - (ymin_end - ymin_start)*ymult
Ymax ymax_end - (ymax_end - ymax_start)*ymult
PlotContour /* do the appropriate plot */
Pathname Filename /* set the name for this file */
SavePicture /* save it to disk */
Get StopSign
IF RESULT = "T" THEN BREAK
END /* do */
EXIT
/*------------------------------- functions ------------------------------- */
log: /* log base 10 */
arg n
Get Eval "log10("n")" /* kick MathVision to give us the answer to log10(n) */
return(result)
exp: /* exponent base 10 */
arg n
Get Eval "10^"n
return(result)
ERROR: /* Error Diagnostic for return codes */
Get Diagnosis RC
SAY RESULT" on line "SIGL
EXIT